// TODO Implement this library.import 'dart:math';

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
enum ButtonType  {
  Filling,
  Border
}
class CustomButton extends StatelessWidget {
  // @required Color color1,
  // @required Color color2,
  //     VoidCallback onPressed,
  // @required image,
  // @required type,
  // @required String title,
  //     num width = 273,
  // Color fontColor
  final Color color1;
  final Color color2;
  final VoidCallback? onPressed;
  final String? image;
  final ButtonType? type;
  final String title;
  final num? width;
  final num? height;
  final Color? fontColor;

  const CustomButton(
      {Key? key,
      required this.color1,
        required  this.color2,
      this.onPressed,
      this.image,
      this.type = ButtonType.Filling,
      required this.title,
      this.width,
      this.fontColor,
      this.height})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    final deviceSize = MediaQuery.of(context).size;
    final cardWidth = min(deviceSize.width * 0.85,  0.0);
    return Container(
      margin: EdgeInsets.only(left: 10, right: 10),
      height: 50,
      decoration: BoxDecoration(
          gradient: LinearGradient(colors: [color1, color2]), // 渐变色
          borderRadius: BorderRadius.circular(50)),
      child: Container(
          margin: EdgeInsets.all(2),
          decoration: BoxDecoration(
              color: type == ButtonType.Filling ? Colors.transparent : Colors.white,
              borderRadius: BorderRadius.circular(50)),
          child: TextButton(
            onPressed: onPressed,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                image == null || image == ""
                    ? Container()
                    : SvgPicture.string(image!,height: 35,width: 35,),
                Container(
                  width: image == null || image == "" ? 0 : 10,
                ),
                Text(
                  "$title",
                  style: TextStyle(
                    color: fontColor == null ? Colors.white : fontColor,
                    fontSize: 18,
                    fontFamily: "SemiBold",
                  ),
                ),
              ],
            ),
          )),
    );
  }
}
